<?

if(isset($_REQUEST["action"])){
	if($_REQUEST["action"]=="ajouter_menu"){
		$var=array("id"=>"", "ordre"=>"");
		$var["titre"]=$_REQUEST["titre"];
		if($_REQUEST["module"]!=""){
			$var["module"]=$_REQUEST["module"];
			$var["lien"]="";
		}else{
			$var["module"]="";
			$var["lien"]=$_REQUEST["lien"];
		}
		
		$menu=new menu($var);
		$menu->ajouter();
		
	}
	if($_REQUEST["action"]=="editer_menu"){
		$var=$sql->request_single("select * from ".CFG_MYSQL_PREFIX."menu where id=".$_REQUEST["editMenu"]);
		$menu=new menu($var);

		$menu->set_titre($_REQUEST["titre"]);
		if($_REQUEST["module"]!=""){
			$menu->set_module($_REQUEST["module"]);
			$menu->set_lien("");
		}else{
			$menu->set_module("");
			$menu->set_lien($_REQUEST["lien"]);
		}
		
		$menu->maj();
		unset($_REQUEST["editMenu"]);
	}
}


$cfg_params=array();
$res=$sql->request("select * from ".CFG_MYSQL_PREFIX."module_config where module='menus'");
foreach($res as $var){
	$cfg_params[$var->nom]=$var->valeur;
}


$menus=array();
$res=$sql->request("select * from ".CFG_MYSQL_PREFIX."menu order by ordre");
foreach($res as $var){
	$menus[]= new menu($var);
}


$modules=array();
$res=$sql->request("select * from ".CFG_MYSQL_PREFIX."module where actif=1 and menuSite=1 order by nomComplet");
foreach($res as $var){
	$modules[$var->nom]=$var->nomComplet;
}

